<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>垃圾分类查询</title>
<link href="<%=path%>/static/usercss/css/all.css" rel="stylesheet" type="text/css">
<!--[if IE]>
<script>
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()
</script>
<![endif]-->
</head>
<body>
<jsp:include page="/WEB-INF/web/includ/header.jsp"></jsp:include>
<section>
<div class="wrap">
<div class="section">
    <article id="datalist">
  
      <div id="title">
      <h1>我的文章列表</h1>
      <label>分类名称</label>
      <span><a href="<%=path %>/web/article/addArticle.html">发表文论</a></span>
    </div>
    <datalist>
      <table width="684px" border="0" cellspacing="15" cellpadding="0">
        <tr>
          <th>文章标题</th>
          <th>发布时间</th>
          <th>赞</th>
          <th>评论数</th>
          <th>操作</th>
        </tr>
      <c:forEach items="${requestScope.pageInfo.list }" var="article">  
        <tr id="line">
          <td class="textleft"><a href="<%=path%>/web/article/articleSingle?articleId=${article.id}">${article.title }</a></td>
          <td><fmt:formatDate value="${article.inputTime }" pattern="yyyy/MM/dd"/></td>
          <td>${article.praiseCount }</td>
          <td>${article.commentCount }</td>
          <td>
          	<c:if test="${article.timeout}">
          		<a href="<%=path%>/web/userinfo/compileArticle?articleId=${article.id}">修改</a>
         	</c:if>
         	 <a id="delete" href="javaScript:void(0)">删除</a><input type="hidden" value="${article.id}"/>
          </td>
        </tr>
       </c:forEach> 
      </table>
    </datalist>
    <div class="pagination ">
      	<a id="first" href="<%=path%>/web/userinfo/articleList?pageNum=1">« 第一页</a>
    	<a href="<%=path%>/web/userinfo/articleList?pageNum=${requestScope.pageInfo.pageNum-1}" class="number">« 前一页</a>
    	<c:forEach items="${requestScope.pageInfo.navigatepageNums }" var="page">
			<a style="border:1px solid #ddd" id="page${page }" href="<%=path%>/web/userinfo/articleList?pageNum=${page}">${page}</a>
		</c:forEach>
   	 	<a href="<%=path%>/web/userinfo/articleList?pageNum=${requestScope.pageInfo.pageNum+1}" class="number">下一页 »</a>
    	<a href="<%=path%>/web/userinfo/articleList?pageNum=${requestScope.pageInfo.pages}" class="number">最后 »</a>
    </div>
    </article>
<jsp:include page="/WEB-INF/web/includ/aside.jsp"></jsp:include>  
</div>
</div>
</section>
<jsp:include page="/WEB-INF/web/includ/footer.jsp"></jsp:include>
</body>
<script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.js"></script>
<script src="<%=path%>/static/managecss/lib/layer/2.4/layer.js"></script>
<script type="text/javascript">
$(function(){
	var path = "${pageContext.request.contextPath}";
	
	$("#page${requestScope.pageInfo.pageNum}").css("background-color","#666");
	$("#page${requestScope.pageInfo.pageNum}").css("color","#fff");
	
	/*删除文章*/
	$("a[id=delete]").click(function(){
		var d = $(this);
		var articleId = $(this).next().val();
		layer.confirm('确认删除吗？', {
			  btn: ['确定', '取消'] //可以无限个按钮
			  ,
			}, function(index, layero){
				$.post(path+"/web/article/deleteArticle",
						{articleId:articleId},
						function(mes){
							d.parent().parent("tr[id=line]").remove();
							
							layer.close(index);
						});
			
			}, function(index){
			  
				
			});
	});
	
})
</script>



</html>
